Repository navigation
perf(runtime-config): cache env names of runtime config keys - #35
Merged
Merged
Conversation
|
@ops4000 is attempting to deploy a commit to the Nitro Team on Vercel. A member of the Team first needs to authorize it. |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
pi0
approved these changes
Nov 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 Linked issue
None. Nitro v3 already keeps the resolved runtime config in
useRuntimeConfig(_cached), so this only applies to v2, which Nuxt 4 uses.❓ Type of change
📚 Description
useRuntimeConfig(event)runsapplyEnvover the whole runtime config on every request. In Nuxt that means the SSR render plus every internal$fetch. For each key,getEnvconverts the key path to its env name withsnakeCase(key).toUpperCase(). That name only depends on the key, but it is recomputed every time.When I profiled SSR of a Nuxt 4 page on Cloudflare Workers,
snakeCasewas ~75% of the time spent inapplyEnv. This PR caches the env name per key, capped at 5,000 entries in case keys are not bounded. Env values are still read fromprocess.envon every call, and the added test covers that.applyEnvon a runtime config with ~250 nested camelCase keys (Node 26, 3,000 runs after warm-up):applyEnvWe have run the same change as a
pnpm patchin production since October.📝 Checklist
🤖 Generated with Claude Code